

<!-- 重置密码 -->
<template>
	<view class="container">
		<view class="oneRow">
			<view class="list-cell b-b radiusT10">
				<text class="cell-tit">手机号码</text>
				<input v-model="phoneNumber" maxlength="11" class="cell-tip" type="text" value="" placeholder-class="inputHolder" placeholder="请输入注册手机号码"/>
			</view>
			<view class="list-cell b-b">
				<text class="cell-tit">验证码</text>
				<input v-model="verifyCode" class="cell-tip" type="text" value="" placeholder-class="inputHolder" placeholder="输入验证码"/>
				<!-- <view class="verify-Container borderOneRpx">
					获取验证码
				</view> -->
				<verifyCode :phoneNumber="phoneNumber"></verifyCode>
			</view>
			<view class="list-cell b-b">
				<text class="cell-tit">新密码</text>
				<input v-model="newPassword" class="cell-tip" type="password" value="" placeholder-class="inputHolder" placeholder="请设置新密码"/>
			</view>
			<view class="list-cell radiusB10">
				<text class="cell-tit">确认密码</text>
				<input v-model="surePassword" class="cell-tip" type="password" value="" placeholder-class="inputHolder" placeholder="请确认新密码"/>
			</view>
		</view>
		
		
		<!-- 确定 -->
		<view class="oneRow">
			<view @click="resetPassword" class="list-cell save-btn">
				确定
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	import verifyCode from '@/components/verify-code/verify-code'
	
	export default {
		components: {
			verifyCode
		},
		onLoad(options) {
			this.resetFlag = options.resetFlag || 0;
		},
		data() {
			return {
				icon: {
					backBtn: "/static/images/common/return.png"
				},
				
				resetFlag: 0,
				phoneNumber: "",
				verifyCode: "",
				newPassword: "",
				surePassword: ""
			};
		},
		methods: {
			...mapMutations(['logout']),
			
			//重置密码
			resetPassword() {
				
				let that = this;
				var url = "";
				if(this.resetFlag == 0) {
					url = "/CustomerApi/updatePasswordForApi";
				}else if(this.resetFlag == 1) {
					url = "/CustomerApi/retrievePassword";
				}
				that.$api.globalUtil.requestAjax({
					url: url,
					method: "POST",
					data: {
						telephone: that.phoneNumber,
						vcode: that.verifyCode,
						password: that.newPassword,
						rePassword: that.surePassword
					},
					success: function(res) {
						if(res.data.success) {
							that.$api.msg("重置成功");
							
							setTimeout(function() {
								that.logout();
							}, 1500);
						}else {
							that.$api.msg(res.data.msg || "重置失败");
						}
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	page{
		background: #F5F5F5;
	}
	
	// header部分
	.header-Container {
		position: relative;
		width: 100%;
		height: 176rpx;
		overflow: hidden;
		box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.08);
		background: rgba(255, 255, 255, 1);
	
		.leftBtns {
			display: flex;
			align-items: center;
			justify-content: flex-start;
			position: absolute;
			bottom: 0;
			width: 100%;
			height: 86rpx;
	
			.back {
				margin-left: 17rpx;
				width: 44rpx;
				height: 44rpx;
			}
		}
	
		.title {
			position: absolute;
			bottom: 0;
			width: 100%;
			height: 86rpx;
			line-height: 86rpx;
			text-align: center;
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: rgba(51, 51, 51, 1);
		}
	}
	
	.container {
		.oneRow {
			margin-top: 20rpx;
			padding: 0 30rpx;
			border-radius: 10rpx;
			
			.radiusT10 {
				border-radius: 10rpx 10rpx 0 0;
			}
			.radiusB10 {
				border-radius: 0 0 10rpx 10rpx;
			}
			
			.cell-tit {
				width: 120rpx;
				height: 100%;
				text-align: justify;
				
				&::after {
					display: inline-block;
					width: 100%;
					content: '';
					height: 0;
				}
			}
			
			.verify-Container {
				position: relative;
				
				&.borderOneRpx:after {
					border-color: rgba(210,23,40,1);
					border-radius: 44rpx;
				}
				
				width:140rpx;
				height:44rpx;
				line-height: 44rpx;
				border-radius:22rpx;
				text-align: center;
				font-size:22rpx;
				font-family:PingFang;
				color:rgba(210,23,40,1);
			}
		}
	}
	.list-cell{
		display:flex;
		align-items:center;
		padding: 0 40rpx 0 50rpx;
		height: 106rpx;
		line-height:106rpx;
		position:relative;
		background: #fff;
		// justify-content: flex-start;
		
		input {
			text-align: right;
			color: #333333;
		}
		
		.inputHolder {
			font-size:28rpx;
			font-family:PingFang;
			color:#BFBFBF;
			line-height:55px;
		}
		
		&.save-btn{
			justify-content: center;
			margin: 0 auto;
			margin-top: 140rpx;
			width:600rpx;
			height:90rpx;
			line-height: 90rpx;
			background: #FE5E49;
			border-radius:45rpx;
			text-align: center;
			font-size:34rpx;
			font-family:PingFang;
			color:rgba(255,255,255,1);
		}
		&.cell-hover{
			background:#fafafa;
		}
		&.b-b:after{
			left: 30rpx;
			right: 30rpx;
		}
		&.m-t{
			margin-top: 16upx; 
		}
		.cell-more{
			align-self: baseline;
			font-size:$font-lg;
			color:$font-color-light;
			margin-left:10upx;
		}
		.cell-tit{
			margin-right:10upx;
			font-size:28rpx;
			font-family:PingFang;
			color:#666666;
		}
		.cell-tip{
			flex: 1;
			text-align: left;
			margin-left: 35rpx;
			font-size:28rpx;
			font-family:PingFang;
			color:#333333;
			line-height:55rpx;
			
			&.unBind {
				color: #D21728;
			}
			&.unSet {
				color: #999999;
			}
		}
	}
</style>



